from django.db import models
from django.core import validators


class UserModels(models.Model):
    username = models.CharField(max_length=10, null=True,validators=[validators.MaxLengthValidator(10, message="最大长度10"),validators.MinLengthValidator(0, message="不可以没有字符")])
    password = models.CharField(max_length=10, validators=[validators.MaxLengthValidator(10, message="最大长度10"), validators.MinLengthValidator(2,message="不可以没有字符")])
    tel = models.CharField(max_length=11, validators=[validators.RegexValidator("1[345678][0-9]{9}", message="请输入合法的手机号")])


class UserInfModels(models.Model):
    face = models.BooleanField(default=False)
    username = models.CharField(max_length=100, null=True)
    name = models.CharField(max_length=10,  validators=[validators.MaxLengthValidator(10, message="最大长度10"), validators.MinLengthValidator(0, message="不可以没有字符")])
    photo = models.FileField(upload_to="photo")
    sex = models.CharField(max_length=1, validators=[validators.RegexValidator('男|女', '性别只能为男或女')])
    age = models.IntegerField(validators=[validators.MinValueValidator(21, message="最小年龄为21"),validators.MaxValueValidator(150, message="最大年龄为150")])
    money = models.CharField(max_length=99)
    married = models.CharField(max_length=2)
    children = models.CharField(max_length=99)
    house = models.IntegerField()

# name age sex


class collect_all(models.Model):
    this_u = models.CharField(max_length=100 ,null=True)
    this_c = models.ForeignKey(UserInfModels, on_delete=models.CASCADE)


class Leave(models.Model):
    content = models.CharField(max_length=999)
    this_u = models.CharField(max_length=100)
    this_c = models.ForeignKey(UserInfModels, on_delete=models.CASCADE)